package com.cqc.other.designPattern.strategyPattern.strategy1;

/**
 * @author cui
 * @date 2024/10/25 19:39
 * @description Step3：定义枚举类
 **/
public enum AgeGroup {

    YOUNG(new BasicPremiumStrategy(300, 500), new PremiumPremiumStrategy(500, 700)),
    ADULT(new BasicPremiumStrategy(400, 600), new PremiumPremiumStrategy(600, 800)),
    SENIOR(new BasicPremiumStrategy(600, 800), new PremiumPremiumStrategy(800, 1000));

    private PremiumStrategy basicStrategy;
    private PremiumStrategy premiumStrategy;

    AgeGroup(PremiumStrategy basicStrategy, PremiumStrategy premiumStrategy) {
        this.basicStrategy = basicStrategy;
        this.premiumStrategy = premiumStrategy;
    }

    public PremiumStrategy getStrategy(String planType) {
        if ("BASIC".equalsIgnoreCase(planType)) {
            return basicStrategy;
        } else if ("PREMIUM".equalsIgnoreCase(planType)) {
            return premiumStrategy;
        }
        throw new IllegalArgumentException("Invalid planType" + planType);
    }
}
